package br.com.socket.menu;

import java.util.Scanner;

import br.com.socket.core.Main;
import br.com.socket.transmiter.Cliente;

public class Menu extends Thread {

	private String choiceMenu;
	protected Scanner sc; 

	public String getChoiceMenu() {
		return choiceMenu;
	}

	public void setChoiceMenu(String choiceMenu) {
		this.choiceMenu = choiceMenu;
	}
	
	public void run(){
		menu();
	}
	
	public void menu() {
		sc = new Scanner(System.in);
		System.out.println("Cliente esta rodando:");
		System.out.println("1 - Listar Processos Windows");
		System.out.println("2 - ls");
		System.out.println("0 - Finalizar");
		setChoiceMenu(sc.nextLine());
		executarChoice();
	}

	private void executarChoice() {
		while (true){
			switch (getChoiceMenu()) {
			case "0":
				System.exit(1);
				break;
				
			case "1":
				new Cliente("Listar Processos", Main.portCliente).start();
				break;
			case "2":
				new Cliente("Listar Diretorio", Main.portCliente).start();
				break;
			case "ls":
				new Cliente("Listar Diretorio", Main.portCliente).start();
				break;
			default:
				break;
			}
			setChoiceMenu("-1");
			setChoiceMenu(sc.nextLine());
		}
		
	}
}
